#ifndef MAPLOADER_H
#define MAPLOADER_H

#include <vector>
#include <list>
#include <string>
#include "utils/tinyxml.h"
#include "graphics.h"
#include <libxml++/libxml++.h>

class tileSet
{
    public:
        tileSet();
        void load(std::string filename);
        SDL_Surface* getTile(int gid);
    private:
        std::vector<SDL_Surface*> m_tileList;

};

class tmxHandler : public xmlpp::SaxParser
{
public:
    tmxHandler();
    virtual ~tmxHandler();
    std::vector<std::vector<std::vector<int> > > getMap();
    std::string getImagePath();

protected:
    //overrides:
    //virtual void on_start_document();
    //virtual void on_end_document();
    virtual void on_start_element(const Glib::ustring& name,
                                const AttributeList& properties);
    //virtual void on_end_element(const Glib::ustring& name);
    //virtual void on_characters(const Glib::ustring& characters);
    //virtual void on_comment(const Glib::ustring& text);
    //virtual void on_warning(const Glib::ustring& text);
    //virtual void on_error(const Glib::ustring& text);
    //virtual void on_fatal_error(const Glib::ustring& text);
private:
    int m_collumns;
    int m_lines;
    int m_layer;
    int m_collumn;
    int m_line;
    std::vector<std::vector<std::vector<int> > > m_listMap;
    std::string m_imagepath;
};

class maploader
{
    public:
        maploader();
        void loadMap(std::string mapname);
        void draw(graphics *graphs);
        virtual ~maploader();
    protected:
    private:
        int m_width;
        int m_height;
        int m_tileWidth;
        int m_tileHeiht;
        tileSet m_tileSet;
        std::vector<std::vector<std::vector<int> > > m_listMap;

};

#endif // MAPLOADER_H
